package com.mashibing.juc.c_025;

import java.util.Arrays;
import java.util.PriorityQueue;

public class T07_01_PriorityQueque {

    public static void main1(String[] args) {

        PriorityQueue<String> q = new PriorityQueue<>();

        q.add("c");
        q.add("e");
        q.add("a");
        q.add("d");
        q.add("z");

        for (int i = 0; i < 5; i++) {
            System.out.println(q.poll());
        }

    }

    public static void main(String[] args) {

        PriorityQueue<Integer> q = new PriorityQueue<>(Integer::compareTo);

        q.addAll(Arrays.asList(4,5,7,3,1,2,7,8,9,0,5,6));

        for (int i = 0; i < 5; i++) {
            System.out.println(q.poll());
        }

    }

}
